/**
 * 用户模块封装api接口
 */
import request from '@/utils/request'

// 注册接口
export const registerService = ({ username, password, rePassword, email }) => {
  return request.post('/api/user/register', { username, password, rePassword, email })
}

// 登录接口
export const loginService = ({ username, password }) => {
  return request.post('/api/user/login', { username, password })
}

// 退出登录接口
export const logoutService = () => {
  return request.post('/api/user/logout')
}

// 获取用户信息接口
export const getUserInfoService = () => {
  return request.get('/api/userinfo/userinfo')
}

// 更新用户信息接口
export const updateUserInfoService = (userData) => {
  return request.put('/api/userinfo/userinfo', userData)
}

// 上传头像接口
export const uploadAvatarService = (formData) => {
  return request.post('/api/userinfo/avatar', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

